//
//  Meal.swift
//  BuilderPattern
//
//  Created by 好米有易 on 2017/12/14.
//  Copyright © 2017年 好米有易. All rights reserved.
//

import UIKit

class Meal {
    
    private var items:[Item] = []
    
    public func addItem(item: Item){
    
        items.append(item)
    }
    
    public func totalCost() -> Float {
        
        var cost: Float = 0
        
        for item in items {
            
            cost += item.price!()
            
        }
        
        return cost;
    }

    public func showItems() {       
        
        for item in items {
            
            print("Item: " + item.name!())
            
            print("Packing: " + item.packing!().pack!())
            
            print("Price: " + "\(item.price!()) \n")

        }
        
    }
    
}
